﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSSystem.BLL;
namespace WebUI.Controls
{
    public partial class EditCustomerCtrl : BaseEditControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!IsPostBack)
                InitData();
        }

        public void InitData()
        {
            POSSystem.BLL.CustomerType group = POSSystem.BLL.CustomerType.GetAllActiveCustomerType();
            Utilities.LoadDropDownList(ddlCustomerType, group.DefaultView, POSSystem.BLL.CustomerType.ColumnNames.TypeName, POSSystem.BLL.CustomerType.ColumnNames.ID);
        }

        public string CustomerName
        {
            get { return txtName.Text; }
            set { txtName.Text = value; }
        }

        public string Phone
        {
            get { return txtPhone.Text; }
            set { txtPhone.Text = value; }
        }

        public string Fax
        {
            get { return txtFax.Text; }
            set { txtFax.Text = value; }
        }

        public string Mobile
        {
            get { return txtMobile.Text; }
            set { txtMobile.Text = value; }
        }

        public int CustomerType
        {
            get { return ddlCustomerType.SelectedIndex > 0 ? int.Parse(ddlCustomerType.SelectedValue) : 0; }
            set { ddlCustomerType.SelectedValue = value.ToString(); }
        }

        public string Address
        {
            get { return txtAddress.Text; }
            set { txtAddress.Text = value; }
        }

        public string Email
        {
            get { return txtEmail.Text.Trim(); }
            set { txtEmail.Text = value.Trim(); }
        }

        public string Company
        {
            get { return txtCompany.Text; }
            set { txtCompany.Text = value; }
        }

        public decimal? CreditLine
        {
            get { return txtCreditLine.Text.Trim() != "" ? decimal.Parse(txtCreditLine.Text) : (decimal?)null; }
            set { txtCreditLine.Text = value != null ? value.ToString() : ""; }
        }

        public string s_CreditLine
        {
            get { return txtCreditLine.Text; }
            set { txtCreditLine.Text = value; }
        }
    }
}